const { sequelize } = require('../config/database');
const User = require('./user.model');
const UserAddress = require('./userAddress.model');
const Banner = require('./banner.model');
const Category = require('./category.model');
const Goods = require('./goods.model');
const GoodImage = require('./goodImages.model');

// 定义模型关联关系
// 商品和图片的一对多关系
Goods.hasMany(GoodImage, {
  foreignKey: 'goodsId',
  as: 'images'
});

GoodImage.belongsTo(Goods, {
  foreignKey: 'goodsId',
  as: 'goods'
});

// 导出模型
module.exports = { sequelize, User, UserAddress, Banner, Category, Goods, GoodImage };